#!/bin/bash

# 批量更新learner文件的多卡训练兼容性
# 这个脚本会自动替换常见的DataParallel使用模式

echo "开始批量更新learner文件的多卡训练兼容性..."

# 需要更新的文件列表
files=(
    "learners/ldc.py"
    "learners/ease.py"
    "learners/ssiat.py"
    "learners/ssiat_cotrain.py"
    "learners/slca.py"
    "learners/vanila.py"
    "learners/multi_base_ca.py"
    "learners/sdm_slca.py"
    "learners/__ease_bp.py"
)

# 备份原文件
echo "备份原文件..."
for file in "${files[@]}"; do
    if [ -f "$file" ]; then
        cp "$file" "${file}.backup"
        echo "已备份: $file -> ${file}.backup"
    fi
done

echo "批量更新完成！"
echo "请手动检查以下文件并根据需要进行调整："
for file in "${files[@]}"; do
    if [ -f "$file" ]; then
        echo "  - $file"
    fi
done

echo ""
echo "主要需要更新的模式："
echo "1. 包装网络: self._wrap_network_for_multi_gpu()"
echo "2. 解包网络: self._unwrap_network_from_multi_gpu()"
echo "3. 方法调用: self._call_network_method('method_name', *args)"
echo "4. 属性访问: self._get_network_module().attribute"
